
package com.kanjian.music.volley;

import android.app.ActivityManager;
import android.content.Context;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;

public class VolleyQueue {

    private static RequestQueue mImageRequestQueue;

    private static RequestQueue mRequestQueue;

    private static ImageLoader mImageLoader;

    public static BitmapLruCache mBitMapCache;

    private VolleyQueue() {
    }

    public static RequestQueue getRequestQueue() {
        return mRequestQueue;
    }

    public static ImageLoader getImageLoader() {
        return mImageLoader;
    }

    public static RequestQueue getImageRequestQueue() {
        return mImageRequestQueue;
    }

    public static void init(Context context) {
        mImageRequestQueue = Volley.newRequestQueue(context);
        mRequestQueue = Volley.newRequestQueue(context);
        int memClass = ((ActivityManager) (context.getSystemService(Context.ACTIVITY_SERVICE)))
                .getMemoryClass();
        // 使用1/8内存缓存图片
        int cacheSize = 1024 * 1024 * memClass / 8;
        mBitMapCache = new BitmapLruCache(cacheSize);
        mImageLoader = new ImageLoader(mImageRequestQueue, mBitMapCache);
    }

}
